package com.hxd.mall.module.product.search.result

import com.hxd.mall.network.base.BaseRequest.request
import com.hxd.mall.network.service.ManagerFunctionApi
import com.hxd.mall.utils.open.ToastUtil
import javax.inject.Inject

/**
 * @author zhaoyong
 * @description:
 * @date :2019/7/17 11:08 AM
 */
class SearchResultPresenter @Inject constructor(var mView: ISearchResultView) : ISearchResultPresenter {

    override fun getListData(isLoadMore: Boolean, key: String, pageNum: Int?, pageSize: Int?, sort: String, has_coupon: String, chanel: String?, zoneId: String?) {
        if (isLoadMore)
            request(ManagerFunctionApi.mIConfigureFunctionApi.searchProductData(key, pageNum, pageSize, sort, has_coupon, chanel, zoneId), {
                mView.finishRefresh()
                mView.showData(it)
            }, {
                mView.finishFailRefresh()
                ToastUtil.showToast(it.msg ?: "")
            })
        else
            request(ManagerFunctionApi.mIConfigureFunctionApi.searchProductData(key, pageNum, pageSize, sort, has_coupon, chanel, zoneId), mView, {
                mView.finishRefresh()
                mView.showData(it)
            }, {
                mView.finishFailRefresh()
                ToastUtil.showToast(it.msg ?: "")
            })
    }

    override fun getData(isRefresh: Boolean) {
    }

    override fun getVersionInfo() {
    }
}